<%@ page language="java" pageEncoding="UTF-8" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%
    String path = request.getContextPath();
%>
<jsp:include page="/admin/inc/incHead.jsp" flush="false"/>
    <script language="javascript">
        function orderDel(orderId) {
            if (confirm('您确定取消吗？')) {
                window.location.href = "<%=path %>/order/orderDelByAd.action?orderId=" + orderId;
            }
        }

        function orderAccept(orderId) {
            if (confirm('您确定受理订单吗？')) {
                window.location.href = "<%=path %>/order/orderAccept.action?orderId=" + orderId;
            }
        }
        function orderFinish(orderId) {
            if (confirm('您确定完成订单吗？')) {
                window.location.href = "<%=path %>/order/orderFinish.action?orderId=" + orderId;
            }
        }
        function userInfo(userId) {
            var url = "<%=path %>/user/userInfo.action?userId=" + userId;
            window.frames.more.src = url;
            $('#info').modal();
        }

        function orderDetail(orderId) {
            var url = "<%=path %>/order/adminOrderDetail.action?orderId=" + orderId;
            window.frames.more.src = url;
            $('#info').modal();
        }
    </script>
<table class="table table-bordered">
    <tr bgcolor="#E7E7E7">
        <td height="14" colspan="8">订单管理</td>
    </tr>
    <tr align="center">
        <td width="10%">订单编号</td>
        <td width="8%">用户</td>
        <td width="10%">金额</td>
        <td width="16%">下单日期</td>
        <td width="10%">送货邮箱</td>
        <td width="16%">付款方式</td>
        <td width="8%">订单状态</td>
        <td width="22%">操作</td>
    </tr>
    <s:iterator value="#request.orderList" var="order">
        <tr align='center'>
            <td bgcolor="#FFFFFF" align="center">
                <s:property value="#order.orderId"/>
            </td>
            <td bgcolor="#FFFFFF" align="center">
                <a class="btn btn-default" href="#" onclick="userInfo(${order.userId})">用户信息</a>
            </td>
            <td bgcolor="#FFFFFF" align="center">
                ￥<s:property value="#order.orderPrice"/>
            </td>
            <td bgcolor="#FFFFFF" align="center">
                <s:property value="#order.orderDate"/>
            </td>
            <td bgcolor="#FFFFFF" align="center">
                <s:property value="#order.orderEmail"/>
            </td>
            <td bgcolor="#FFFFFF" align="center">
                <s:if test="#order.orderPayType==0">
                    支付宝
                </s:if>
                <s:if test="#order.orderPayType==1">
                    银行卡
                </s:if>
            </td>
            <td>
                <s:if test="#order.orderState==0">
                    未确认
                </s:if>
                <s:if test="#order.orderState==1">
                    已确认<br/>未发货
                </s:if>
                <s:if test="#order.orderState==2">
                    已完成
                </s:if>
                <s:if test="#order.orderState==3">
                    已取消
                </s:if>
            </td>
            <td bgcolor="#FFFFFF" align="center">
                <a href="#" onclick="orderDetail(${order.orderId})" class="btn btn-default">明细</a>
                <s:if test="#order.orderState==0">
                    <a href="#" onclick="orderAccept(${order.orderId})"
                       class="btn btn-success">受理</a>
                </s:if>
                <s:if test="#order.orderState==1">
                    <a href="#" onclick="orderFinish(${order.orderId})"
                       class="btn btn-success">完成</a>
                </s:if>
                <s:if test="#order.orderState==0">
                    <a href="#" onclick="orderDel(<s:property value="#order.orderId"/>)" class="btn btn-danger">取消</a>
                </s:if>
            </td>
        </tr>
    </s:iterator>
</table>
<jsp:include page="/common/page.jsp" flush="true"/>
<jsp:include page="/admin/inc/incFoot.jsp" flush="false"/>